import http from '../utils/Http'
import validate from '../utils/Validate'

//接口API统一
export default class api {

    //获取产品和分类信息
    static apiTypesAndProduct(param) {
      return http.get('purchase/v1/loadProducts',param).then(resp => resp)
    }
   //微信用户手机登录
    static apiLogin(param) {
      return http.post('purchase/v1/login/in',param).then(resp => resp)
    }

  
   //保存采购产品信息
    static apiSaveItemList(param) {
      return http.post('purchase/v1/saveItemList',param).then(resp => resp)
    }


    //上传文件
    static apiUploadFile(url, filePath, name, formData, cb , ccb) {
      console.log("========调用上传图片方法============",url);
      wx.uploadFile({
        url: http.baseUrl + url,
        filePath: filePath,
        name: name,
        header: http.createAuthHeaderFile(),
        formData: formData, // HTTP 请求中其他额外的 form data
        success: function (res) {
          if (res.statusCode == 200 && !res.data.result_code) {
            return typeof cb == "function" && cb(res.data)
          } else {
            return typeof cb == "function" && cb(false)
          }
        },
        fail: function () {
          return typeof cb == "function" && cb(false)
        },
        complete:function () {
          return typeof ccb == "function" && ccb()
        }
      })
    }

}
